package com.example.web05.exception;

import com.example.web05.utils.ResultCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 业务层的自定义异常
 */
@Data   //添加getter和setter方法
@EqualsAndHashCode(callSuper = true)    //继承父类的属性
public class ServiceException extends RuntimeException{
    private ResultCode resultCode;  //维护一个错误码

    public ServiceException(String msg){
        super(msg);
    }
    public ServiceException(ResultCode resultCode) {
        super(resultCode.getCode() + ":" + resultCode.getMsg());
        this.resultCode = resultCode;
    }

}
